#include "TorusP.h"

TorusP::TorusP( float inner, float outer, int slices, int loops, Material *mat, Texture *tex ):Primitive(mat,tex)
{
	this->inner=inner;
	this->outer=outer;
	this->slices=slices;
	this->loops=loops;
	glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR );
	glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR );
}

void TorusP::act(float texLS, float texLT)
{
	float ls,lt;
	if(tex->inheritTex){
		ls=texLS;
		lt=texLT;
	}
	else{
		ls=getTex()->getLengthS();
		lt=getTex()->getLengthT();
	}

	getMat()->act();
	getTex()->act();
	
	
	glEnable(GL_TEXTURE_GEN_S);
	glEnable(GL_TEXTURE_GEN_T);

	glutSolidTorus(inner,outer,slices,loops);

	glDisable(GL_TEXTURE_GEN_S);
	glDisable(GL_TEXTURE_GEN_T);
}
